package org.snusmumr.android.media;

import org.snusmumr.android.media.Constants.ImportExportTask;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class ImportExportActivity extends Activity {
	private ImportExportTask task;
	private String fileName;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.imp_ext_activity);
		this.task = (ImportExportTask) getIntent().getExtras().get(Constants.KEY_TASK_TYPE);
		this.fileName = getIntent().getExtras().getString(Constants.KEY_PATH);
		
		TextView title = (TextView) findViewById(R.id.tv_imp_ext_title);
		TextView summary = (TextView) findViewById(R.id.tv_imp_ext_summary);
		TextView path = (TextView) findViewById(R.id.tv_imp_exp_path);
		Button actionButton = (Button) findViewById(R.id.btn_do_export_import);
		Button cancelButton = (Button) findViewById(R.id.btn_imp_exp_cancel);
		switch (task) {
		case Export:
			title.setText(R.string.settings_export_title);
			summary.setText(R.string.settings_export_summary);
			path.setText(fileName);
			actionButton.setText(R.string.settings_export_title);
			actionButton.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					doExport();
				}
			});
			break;
			
		case Import:
			title.setText(R.string.settings_import_title);
			summary.setText(R.string.settings_import_summary);
			path.setText(fileName);
			actionButton.setText(R.string.settings_import_title);
			actionButton.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					doImport();
				}
			});
			break;
		default:
			break;
		}
		
		cancelButton.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				ImportExportActivity.this.finish();
			}
		});
	}
	
	private void doImport() {
		Toast.makeText(this, "do import", Toast.LENGTH_SHORT);
	}
	
	private void doExport() {
		Toast.makeText(this, "do export", Toast.LENGTH_SHORT);
	}
}
